﻿using System.Threading;
using System;
using Silverlight.Training.Client.Common.ServiceReference.EventArgs;
using System.ComponentModel;
using Silverlight.Training.Client.Common.ServiceReference.Contracts;
using Silverlight.Training.Client.Common.ServiceReference.Interfaces;
using Silverlight.Training.Client.Common.ServiceReference.Feedbacks;

namespace Silverlight.Training.Client.Common.ServiceReference.Operations
{
    public partial class EMServiceClient
    {
        #region GetEmployeeTypeCollection

        public event EventHandler<CollectionFeedbackCompletedEventArgs<EmployeeType>> GetEmployeeTypeCollectionCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IEMService.BeginGetEmployeeTypeCollection(AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetEmployeeTypeCollection(callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        CollectionFeedback<EmployeeType> IEMService.EndGetEmployeeTypeCollection(IAsyncResult result)
        {
            return base.Channel.EndGetEmployeeTypeCollection(result);
        }

        private IAsyncResult OnBeginGetEmployeeTypeCollection(object[] inValues, AsyncCallback callback, object asyncState)
        {
            return ((IEMService)(this)).BeginGetEmployeeTypeCollection(callback, asyncState);
        }

        private object[] OnEndGetEmployeeTypeCollection(IAsyncResult result)
        {
            CollectionFeedback<EmployeeType> retVal = ((IEMService)(this)).EndGetEmployeeTypeCollection(result);
            return new object[] {
                retVal};
        }

        private void OnGetEmployeeTypeCollectionCompleted(object state)
        {
            if ((this.GetEmployeeTypeCollectionCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetEmployeeTypeCollectionCompleted(this, new CollectionFeedbackCompletedEventArgs<EmployeeType>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetEmployeeTypeCollectionAsync()
        {
            this.GetEmployeeTypeCollectionAsync(null);
        }

        public void GetEmployeeTypeCollectionAsync(object userState)
        {
            if ((this.onBeginGetEmployeeTypeCollectionDelegate == null))
            {
                this.onBeginGetEmployeeTypeCollectionDelegate = new BeginOperationDelegate(this.OnBeginGetEmployeeTypeCollection);
            }
            if ((this.onEndGetEmployeeTypeCollectionDelegate == null))
            {
                this.onEndGetEmployeeTypeCollectionDelegate = new EndOperationDelegate(this.OnEndGetEmployeeTypeCollection);
            }
            if ((this.onGetEmployeeTypeCollectionCompletedDelegate == null))
            {
                this.onGetEmployeeTypeCollectionCompletedDelegate = new SendOrPostCallback(this.OnGetEmployeeTypeCollectionCompleted);
            }
            base.InvokeAsync(this.onBeginGetEmployeeTypeCollectionDelegate, null, this.onEndGetEmployeeTypeCollectionDelegate, this.onGetEmployeeTypeCollectionCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetEmployeeTypeCollectionDelegate;

        private EndOperationDelegate onEndGetEmployeeTypeCollectionDelegate;

        private SendOrPostCallback onGetEmployeeTypeCollectionCompletedDelegate;

        private partial class EMServiceClientChannel
        {
            public IAsyncResult BeginGetEmployeeTypeCollection(AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[0];
                IAsyncResult _result = base.BeginInvoke("GetEmployeeTypeCollection", _args, callback, asyncState);
                return _result;
            }

            public CollectionFeedback<EmployeeType> EndGetEmployeeTypeCollection(IAsyncResult result)
            {
                object[] _args = new object[0];
                CollectionFeedback<EmployeeType> _result = ((CollectionFeedback<EmployeeType>)(base.EndInvoke("GetEmployeeTypeCollection", _args, result)));
                return _result;
            }
        }

        #endregion

        #region GetSingleEmployeeType

        public event EventHandler<SingleFeedbackCompletedEventArgs<EmployeeType>> GetSingleEmployeeTypeCompleted;

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        IAsyncResult IEMService.BeginGetSingleEmployeeType(int eTypeID, AsyncCallback callback, object asyncState)
        {
            return base.Channel.BeginGetSingleEmployeeType(eTypeID, callback, asyncState);
        }

        [EditorBrowsableAttribute(EditorBrowsableState.Advanced)]
        SingleFeedback<EmployeeType> IEMService.EndGetSingleEmployeeType(IAsyncResult result)
        {
            return base.Channel.EndGetSingleEmployeeType(result);
        }

        private IAsyncResult OnBeginGetSingleEmployeeType(object[] inValues, AsyncCallback callback, object asyncState)
        {
            int eTypeID = ((int)(inValues[0]));
            return ((IEMService)(this)).BeginGetSingleEmployeeType(eTypeID, callback, asyncState);
        }

        private object[] OnEndGetSingleEmployeeType(IAsyncResult result)
        {
            SingleFeedback<EmployeeType> retVal = ((IEMService)(this)).EndGetSingleEmployeeType(result);
            return new object[] {
                retVal};
        }

        private void OnGetSingleEmployeeTypeCompleted(object state)
        {
            if ((this.GetSingleEmployeeTypeCompleted != null))
            {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GetSingleEmployeeTypeCompleted(this, new SingleFeedbackCompletedEventArgs<EmployeeType>(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }

        public void GetSingleEmployeeTypeAsync(int eTypeID)
        {
            this.GetSingleEmployeeTypeAsync(eTypeID, null);
        }

        public void GetSingleEmployeeTypeAsync(int eTypeID, object userState)
        {
            if ((this.onBeginGetSingleEmployeeTypeDelegate == null))
            {
                this.onBeginGetSingleEmployeeTypeDelegate = new BeginOperationDelegate(this.OnBeginGetSingleEmployeeType);
            }
            if ((this.onEndGetSingleEmployeeTypeDelegate == null))
            {
                this.onEndGetSingleEmployeeTypeDelegate = new EndOperationDelegate(this.OnEndGetSingleEmployeeType);
            }
            if ((this.onGetSingleEmployeeTypeCompletedDelegate == null))
            {
                this.onGetSingleEmployeeTypeCompletedDelegate = new SendOrPostCallback(this.OnGetSingleEmployeeTypeCompleted);
            }
            base.InvokeAsync(this.onBeginGetSingleEmployeeTypeDelegate, new object[] {
                    eTypeID}, this.onEndGetSingleEmployeeTypeDelegate, this.onGetSingleEmployeeTypeCompletedDelegate, userState);
        }

        private BeginOperationDelegate onBeginGetSingleEmployeeTypeDelegate;

        private EndOperationDelegate onEndGetSingleEmployeeTypeDelegate;

        private SendOrPostCallback onGetSingleEmployeeTypeCompletedDelegate;

        private partial class EMServiceClientChannel
        {
            public IAsyncResult BeginGetSingleEmployeeType(int eTypeID, AsyncCallback callback, object asyncState)
            {
                object[] _args = new object[1];
                _args[0] = eTypeID;
                IAsyncResult _result = base.BeginInvoke("GetSingleEmployeeType", _args, callback, asyncState);
                return _result;
            }

            public SingleFeedback<EmployeeType> EndGetSingleEmployeeType(IAsyncResult result)
            {
                object[] _args = new object[0];
                SingleFeedback<EmployeeType> _result = ((SingleFeedback<EmployeeType>)(base.EndInvoke("GetSingleEmployeeType", _args, result)));
                return _result;
            }
        }

        #endregion

    }
}
